package com.pureut.quality.controller;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.quality.domain.dto.PatrolSampleInspectionDto;
import com.pureut.quality.domain.dto.QualityPatrolInspectionDocumentDto;
import com.pureut.quality.domain.dto.SampleInspectionDto;
import com.pureut.quality.domain.vo.*;
import com.pureut.quality.service.QualityPatrolSampleInformationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/***
 * 巡检样本信息控制层
 * Author:C
 * Date:2023/02/13 14:22
 * @DESC
 */
@RestController
@RequestMapping("/quality-patrol-sample-information")
public class QualityPatrolSampleInformationController extends BaseController {

    @Resource
    QualityPatrolSampleInformationService qualityPatrolSampleInformationService;

    /**
     * 巡检样本信息列表
     */
    @GetMapping("/list")
    public TableDataInfo getList(String patrolInspectionSheetNo) {
        startPage();
        //查询巡检样本信息列表
        List<PatrolSampleInspectionDto> list = qualityPatrolSampleInformationService.getPatrolSampleInformationList(patrolInspectionSheetNo);
        return getDataTable(list);
    }

    /**
     * 保存（小保存）
     */
    @PostMapping("/add")
    @Log(title = "保存（巡检样品信息）", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody PatrolSampleAddVo patrolSampleAddVo) {
        return toAjax(qualityPatrolSampleInformationService.add(patrolSampleAddVo));
    }

    /**
     * 保存
     */
    @PostMapping("/addDocument")
    @Log(title = "保存", businessType = BusinessType.INSERT)
    public AjaxResult addDocument(@RequestBody PatrolAddDocumentVo patrolAddDocumentVo) {
        return toAjax(qualityPatrolSampleInformationService.addDocument(patrolAddDocumentVo));
    }
}
